<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>数演大数据交换平台</title>
    <link href="../assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <link href="../assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="../assets/global/plugins/layui/css/layui.css"/>
    <link rel="stylesheet" href="../assets/custom/css/changeIndex.css"/>
    <link rel="stylesheet" href="../assets/custom/css/changeother.css"/>
    <link rel="stylesheet" href="../assets/custom/css/login.css"/>

</head>
<body >
    <div class="login">
        <div class="login-content">
        <div class="bannerW">
         <div class="login-logo"><img src="../assets/custom/img/login-logo.png" alt=""></div>
        <form class="login-form">
            <div class="login-welcome"><h3>WELCOME TO LOGIN</h3><h4>欢迎登录</h4></div>
            <div class="login-group">
                <div class="form-input">
                    <input type="text" name="user" class="login-username" required placeholder="用户名/邮箱">
                    <i class="icon-user"></i>
                </div>
                <div class="form-input form-input-last">
                    <input type="password" name="psd" class="login-password" required placeholder="密码">
                    <i class="icon-lock"></i>
                </div>
                <div class="login-btn">
                    <button class="btn blue-hoki btn-login">登录</button>
                </div>
            </div>
        </form>
        </div>
        </div>
        <div class="login-foot">
            <div class="bannerW">
                <div class="fl"><span class="copyright">copyright &copy; 2013-2018 All Rights Reserved 数演科技版权所有</span></div>
                <div class="fr"><span class="copyright">关于我们 法律声明及隐私政策 友情链接</span></div>
            </div>
        </div>
    </div>
    <script src="../assets/global/plugins/jquery.min.js" type="text/javascript"></script>
    <script src="../assets/global/plugins/layui/layui.all.js"></script>
    <script src="../assets/pages/scripts/jquery.validate.js"></script>
    <script>
        var base = 'http://127.0.0.1:8094';
        $('.btn-login').click(function () {
            userMsg();
        });


        $(document).keydown(function(event){
            if(event.keyCode === 13){
                userMsg();
            }
        });

        $(".login-form").validate({
            debug:true,
            messages:{
                "user":{
                    required: "请输入你的账户名"
                },
                "psd":{
                    required: "请输入你的密码",
                }
            },
        });

        function userMsg() {
            var uname = $('.login-username').val();
            var psd = $('.login-password').val();
            if(uname ==='' || psd === ''){
                return;
            }else {
                $.ajax({
                    url : base + '/login',
                    type : 'POST',
                    dataType :'JSON',
                    data : {'username': uname,'password':psd},
                    success : function (result) {
                        if (result.code === 500){
                            layer.msg('用户名或密码错误')
                        }else if (result.code === 0){
                            $(window).attr('location',base+'/index');
                        }
                    }
                });
            }

        }
    </script>
</body>
</html>